The file infer_polling_place_assignments.py assigns polling places to registrants. To run it requires three files. 

The first file supplied here is voter_file_pa_huntingdon.csv. This contains administrative metadata on registrants such as the precint at which they are assigned and the county in which they registered. This file also contains the geo coordinates of each registrant's home address. 

The second file is a pickle file called physical_information_pa_strict.pkl, this file contains a python dictionary where the keys are the number of polling places across all years and the values are metadata which describe the physical characteristics of that place. Pertinently, this file contains the geo coordinates of each polling place as well as all of the address metadata. Each unique physical polling place is assigned a unique id referred to as UID. This UID can be connected to the UID in the dictionary loaded in by administrative_information_pa_strict.pkl. 

The third file is a pickle file called administrative_information_pa_strict.pkl, this file contains a python dictionary where the keys are indicies of polling places and the values are metadata which describe the administrative characteristics of that place. For example, the precinct identifier at this place. 


infer_polling_place_assignments.py matches relies on two functions for each state, a function which converts metadata on a registrant into a lookup string for that registrant's polling place (this is usually some combination of precinct id or precinct name along with registration county) and a function which converts the administrative metatdata from the state file into a form which will align with the registrants lookup string. The first function is called match_a_row (as it matches a single registrant or row) and the second function is called match_a_state (as it cleans the state supplied file to match the format of the voter file).

To run infer_polling_place_assignments.py see the script compute_distance.sh. 

This file uses python version 3.6 and requires the packages: pandas(1.1.5), geopy(2.2.0), numpy (1.17.0), the remaining requirements are default python modules and should not require installation. 
